package com.jlcindia.struts2;

import java.io.*;
import java.io.FileInputStream;

import com.opensymphony.xwork2.ActionSupport;

public class FileUpload extends ActionSupport {
	private File resume;
	private String resumeContentType;
	private String resumeFileName;
	private long size;
	public File getResume() {
		return resume;
	}
	public void setResume(File resume) {
		this.resume = resume;
	}
	public String getResumeContentType() {
		return resumeContentType;
	}
	public void setResumeContentType(String resumeContentType) {
		this.resumeContentType = resumeContentType;
	}
	public String getResumeFileName() {
		return resumeFileName;
	}
	public void setResumeFileName(String resumeFileName) {
		this.resumeFileName = resumeFileName;
	}
	public long getSize() {
		return size;
	}
	public void setSize(long size) {
		this.size = size;
	}
	public String execute(){
		System.out.println("file uploading..........");
		String path="E:/";
		FileInputStream in=null;
		FileOutputStream out=null;
		try{
			size=getResume().length();
			System.out.println(resumeFileName);
			System.out.println(size);
			System.out.println(resumeContentType);
			in=new FileInputStream(getResume());
			String destFileName=path+resumeFileName;
			File destFile=new File(destFileName);
			if(!destFile.exists()){
				out=new FileOutputStream(destFile);
				int c;
				while((c=in.read())!=-1){
					out.write(c);
				}
			}
			in.close();
			out.close();
			return "success";
			
		}catch(Exception e){
			e.printStackTrace();
			return "input";
		}
	}

}
